package com.xyc.gulimall.order.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

//订单确认页需要用的数据
@Data
public class OrderConfirmVo {

    //收货地址
    private List<MemberAddressVo> addressVos;

    //所有选中的购物项
    private List<OrderItemVo> itemVos;

    //发票记录...

    //优惠卷信息...
    private Integer integration;

    Map<Long,Boolean> stocks;

    //订单防重令牌
    private String orderToken;

    public Integer getCount() {
        Integer i = 0;
        if (itemVos != null) {
            for (OrderItemVo item : itemVos) {
                i += item.getCount();
            }
        }
        return i;
    }

    //订单总额
    private BigDecimal total;

    public BigDecimal getTotal() {
        BigDecimal sum = new BigDecimal("0");
        if (itemVos != null) {
            for (OrderItemVo item : itemVos) {
                sum = sum.add(item.getPrice().multiply(new BigDecimal(item.getCount())));
            }
        }
        return sum;
    }

    //应付价格
    private BigDecimal payPrice;

    public BigDecimal getPayPrice() {
        return getTotal();
    }
}
